{include file="public/header" /}
<body>
<div class="layui-card">
    <div class="layui-card-body">
        <div class="layui-tab-content">
            <form id="positionFormData" class="layui-form layui-form-pane" autocomplete="off">
                <input type="hidden" name="id" value="{$info.id}">
                <div class="layui-form-item">
                    <label class="layui-form-label layui-required">名称</label>
                    <div class="layui-input-block">
                        <input type="text" name="name" value="{$info.name}" id="positionName" class="layui-input" placeholder="请输入职位名称">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">排序</label>
                    <div class="layui-input-block">
                        <input type="text" name="sort" value="{$info.sort}" id="sort" class="layui-input" placeholder="请输入排序，数字越小，排序越靠前">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">状态</label>
                    <div class="layui-input-block">
                        <input type="checkbox" name="status" id="status" {if $info.status == 1}checked{/if} lay-text="显示|隐藏" lay-skin="switch">
                    </div>
                </div>

                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <!--<button type="submit" lay-submit lay-filter="add" class="layui-btn layui-btn-normal">提交</button>-->
                        <button type="button" onclick="sendPositionFormData()" class="layui-btn layui-btn-normal"><i class="fa fa-check"></i>提交</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
</body>

<script>
    layui.use('form',function () {
        var $ = layui.jquery,
            form = layui.form

    });

    function sendPositionFormData() {
        //弹出遮罩层，防止多次点击
        var positionLoad = layer.load(1,{shade:[0.5,'#FFF'],time:0})
        let data = $("#positionFormData").serialize()
        ajaxRequest("{:url('company/editPosition')}",data,function (res) {
            if (res.code == 'suc'){
                sucMsg(res.msg,function(){
                    //刷新父级页面
                    parent.layui.table.reload('positionList')
                    //关闭遮罩层
                    layer.close(positionLoad)
                    //关闭当前弹出层
                    xadmin.close()
                })
            }else {
                errMsg(res.msg,function () {
                    //关闭遮罩层
                    layer.close(positionLoad)
                })
            }
        })
    }
</script>